﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace JmShared
{
    public enum ChatType
    {
        PrivateMessage,
        GroupChat,
        Undefined
    }

    public enum GroupPrivilege
    {
        [EnumDescription("Member")]
        Member = 0,
        [EnumDescription("Moderator")]
        Moderator = 5,
        [EnumDescription("Owner")]
        Owner = 9
    }

    public enum FileTransferType
    {
        CustomEmoticon,
        Avatar
    }


    /// <summary>
    /// Commands that the client may send to the server.
    /// </summary>
    public enum ClientCommands
    {
        Undefined,
        AndroidSettings,
        CustomEmoticon,
        DeviceStatusUpdate,
        Login,
        Message,
        NotificationsUpdate,
        PcSettings,
        RegisterAccount,
        ResetPassword,
        VerifyResetPasswordMail,
        VerifyRegisterAccountMail,
        WpSettings,
        RequestEmoticon,
        SetGroupPrivilege,
        FileTransfer,
        RequestPrivateMessages,
        RequestGroupMessages,
        RequestAvatar,
        Avatar
    }
    /// <summary>
    /// Commands that the server may send to the client.
    /// </summary>
    public enum ServerCommands
    {
        Undefined,
        ServerInfoMessage,
        ChatReceipt,
        ClientList,
        LoginResponse,
        Message,
        DeviceStatusUpdate,
        CustomEmoticon,
        NotificationsUpdate,
        Avatar,
        RequestEmoticon,
        RequestAvatar,
        MessageQueue,
        FileTransfer
    }

    [DataContract]
    public enum DeviceType
    {
        [EnumMember(Value = "pc")]
        PC = 0,
        [EnumMember(Value = "wp")]
        WindowsPhone,
        [EnumMember(Value = "android")]
        Android,
        [EnumMember(Value = "other")]
        other
    }
    [DataContract]
    public enum ClientStatus
    {
        [EnumMember]
        Available = 0,
        [EnumMember]
        Busy = 1,
        [EnumMember]
        Afk = 2,
        [EnumMember]
        Offline = 3
    }

    public enum MessageType
    {
        Error = 0,
        Logout,
        IsWriting,
        Nudge,
        GroupMessage,
        PrivateMessage,
        SendPushUri,
        /// <summary>
        /// Group ID as Message
        /// </summary>
        CreateGroup,
        /// <summary>
        /// Group ID as Message
        /// </summary>
        DeleteGroup,
        /// <summary>
        /// Friend UserName as RecipientID, JSON serialized JmShared.ChatGroup as Message
        /// </summary>
        SendGroupInvite,
        /// <summary>
        /// Group ID as RecipientID
        /// </summary>
        AcceptGroupInvite,
        /// <summary>
        /// Friend UserName as RecipientID
        /// </summary>
        SendFriendRequest,
        /// <summary>
        /// Friend UserName as RecipientID
        /// </summary>
        AcceptFriendRequest,
        ResetUnreadMessageCount,
        UpdateNotifications,
        /// <summary>
        /// Friend UserName as RecipientID
        /// </summary>
        DeclineFriendRequest,
        /// <summary>
        /// Group ID as RecipientID
        /// </summary>
        DeclineGroupInvite,
        /// <summary>
        /// Username as RecipientID
        /// </summary>
        IgnoreContact,
        /// <summary>
        /// Username as RecipientID
        /// </summary>
        UnignoreContact,
        /// <summary>
        /// Group ID as RecipientID
        /// </summary>
        UnblockGroup,
        /// <summary>
        /// Group ID as RecipientID
        /// </summary>
        BlockGroup,
        /// <summary>
        /// Group ID as RecipientID
        /// </summary>
        LeaveGroup,
        /// <summary>
        /// Group ID as RecipientID, new group name as Message
        /// </summary>
        RenameGroup,
        /// <summary>
        /// Username as RecipientID, Group ID as message.
        /// </summary>
        RemoveMemberFromGroup,
        SetGroupPrivilegeForMember,
        /// <summary>
        /// Notification ID as RecipientID
        /// </summary>
        DismissServerMessageNotification,
        ///// <summary>
        ///// Stops messages to the client, in preparation for logout.
        ///// </summary>
        //PrepareLogout,
        /// <summary>
        /// Let the server know the client is successfully logged in, and prepared to receive messages.
        /// </summary>
        ClientReady

    }

    public enum NotificationType
    {
        [EnumDescription("Friend Request")]
        FriendInvite,
        [EnumDescription("Group Invitation")]
        GroupInvite,
        [EnumDescription("Server Message")]
        ServerMessage,
        [EnumDescription("NYI")]
        Other,
        [EnumDescription("Update")]
        UpdateAvailable
    }

    public enum ServerInfoMessageType
    {
        ContactAuthenticated,
        UserInfoUpdated,
        ContactDisconnected
    }

    public enum UserInfoAttributeType
    {
        FontFamily,
        FontWeight,
        FontStyle,
        FontColor,
        Nickname,
        Avatar,
        ChatGroups,
        Notifications,
        CustomEmoticons
    }

    public enum UserSettingsType
    {
        PcSettings,
        WpSettings,
        AndroidSettings,
        BaseSettings
    }

    [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
    public class EnumDescriptionAttribute : Attribute
    {
        private readonly string description;
        public string ResourceKey { get; set; }
        public string Description { get { return description; } }
        public EnumDescriptionAttribute(string description)
        {
            this.description = description;
        }
    }

}
